First look at Delphi XE
This week’s just getting started, and it’s already had more than enough awesomeness to pack into a typical month. The new version of Delphi came out yesterday. Metroid: Other M and The Way of Kings, a new Brandon Sanderson book, were both released today. (I have a feeling I’m going to be more distracted than usual for a while…) But as awesome as Metroid games and anything by Sanderson tend to be, (if you’re into fantasy at all, check out Elantris and Mistborn and prepare to be blown away,) this is a programming blog, and I’m supposed to be talking about Delphi. So here’s the good, the bad, and the annoying about my first impressions with Delphi XE.
The first thing I knew about the release was when I received my SA email yesterday afternoon, as opposed to having to wait a few days or even weeks to get my upgrade as has happened in previous years. Big improvement there, and I hope Embarcadero keeps it up for subsequent releases. Good.
No OSX support, which we all thought was going to be in this release up until a few weeks ago. Bad. But it’s not there because the people at Embarcadero preferred to focus on quality and not release something that wasn’t ready. Good. No one wants to see (or pay for) another D8.
So I open it up and start browsing through some code. My settings from D2010 didn’t get migrated forward. Annoying. There really should be some way to import them as part of the installation process.
ErrorInsight is the same old same old, with false positives all over the place because it can’t find basic standard library units. Annoying. But at least it doesn’t choke on methods of objects from a generic list anymore. Good.
Speaking of Generics, huge improvement here. I was able to go through my codebase and remove all the annoying workarounds for generics-related glitches, and it compiles and runs properly now! Good.
When it’s time to debug, I immediately noticed a few improvements. We finally, finally, after all these years, have debug DCPs available for the standard libraries. (For those not familiar with them, DCPs are to Delphi packages as DCUs are to units.) That means that people like me who build stuff with packages are able to trace into the RTL when debugging. Good.
Also, something that always drove me up the wall about the debugger has been fixed. When you put the cursor in an expression and hit CTRL-F7, it pops up the Evaluate/Modify window and evaluates whatever you had the cursor on. But if you moved the cursor and hit CTRL-F7 again without closing the Evaluate/Modify window, it would focus the Evaluate/Modify window, but it wouldn’t evaluate the new expression you had selected. You’d have to close the window and hit CTRL-F7 again to get a new evaluation. (Or copy/paste or type it in, of course.) That always bugged me, but it’s been fixed in XE. Good.
And while we’re on the subject of Evaluate/Modify, you can now select more than whatever the limit used to be (80 characters?) and have your entire selection copied when you hit CTRL-F7. Good.
But while poking around in there, I found a new way to crash the IDE. Try to evaluate a call that will open a form, and it locks up Evaluate/Modify. Then hit CTRL-F2 to kill the debugger, and it brings the whole program down. Bad. (Not sure if this was in earlier versions, though. I’ve never run across it before.)
Oh, there’s a new regular expression library in the RTL. Some people will probably find this a good thing. I personally see it as Annoying. Delphi code is supposed to be easy to read. That’s an explicit design goal going all the way back to Wirth. But PCREs are anything but, and having it right there in the standard library will just encourage people to use them in code that I might end up having to debug some day.
In addition to Generics bugs getting cleaned up, the Generics.Defaults and Generics.Collections units got a bit of polish. There were some minor tweaks to speed up various low-level comparison functions in Generics.Defaults. Over in Generics.Collections, all the collections have gained a ToArray method, TStack<T> and TQueue<T> gained a Capacity, and there’s a new TThreadedQueue<T> class that looks a lot like the Blocking Collection that Primoz Gabrijelcic set up for OmniThreadLibrary, only without all the Omni stuff. These new features look Good.
The Math unit has been given overloads for Single, Double and Extended precision versions of just about all its calculation routines, which is Good because there’s no more implicit conversions to introduce rounding errors. However, I had this bite me when compiling some code at work. Someone was passing an array of integers to Math.Sum, which worked before, but now the compiler gave an ambiguous overload error for that. Annoying, but not too hard to fix, since there’s a SumInt function right after Sum. Not sure why the original author of this code didn’t use it in the first place. Oh well…
In RTTI.pas, there’s a new class called TMethodImplementation. You create it and give it data that describes the signature of a method, then pass it an anonymous method that takes an array of TValues and returns a TValue, and it creates a little thunk of machine code that builds a function with the correct signature that invokes your anonymous method. Very cool, lots of potential… except that you can’t use it. The constructor’s private, and there’s a public constructor that raises an exception, so you can’t get at it via TObject.Create. It’s apparently for internal use only. Annoying. I asked Allen Bauer about this, and he said that it’s because they weren’t sure they had the final form of the class worked out yet, and they didn’t want to make it publicly available yet in a form that they’d end up having to preserve and support forever afterwards.
There’s also a new class called TVirtualMethodInterceptor that is publicly available, and uses TMethodImplementation internally to allow you to replace virtual methods on a class. I’m a bit curious as to what this is useful for, but apparently the team thought it was good for something, because a lot of work went into setting it up. Good?
Oh, and apparently certain aspects of the compiler have slowed down. Most things will compile about the same speed or even a little faster, but for really large projects (millions of lines) with complex interdependencies between units, you’ll notice some slowdown, and it’ll apparently get worse the larger your project is. I timed it at work, on a project of about 3.5 million lines of code. It builds in about 2 minutes on D2010, closer to 3 minutes on XE. Bad, but still a heck of a lot better than the C family could do. And apparently it has something to do with making Generics work right, so I can tolerate that. Hopefully they’ll find some way to regain some of that lost speed in updates, though.
Oh, and there are little {$IFDEF POSIX} and {$IFDEF MACOS} tags scattered throughout the RTL and VCL, even more than there were in Delphi 2010. This is Good if you’re looking forward to OSX or Linux cross-platform development in the next release(s). I haven’t seen any 64-bit ifdefs, but that could be because it doesn’t require much change at the Pascal level, the way a completely different OS platform does. (UPDATE: According to PhiS, there’s a lot of {$IFDEF CPUX64} tags in System.pas. I was poking around the libraries with BeyondCompare last night but I didn’t bother to look in there because I knew that, with all the cross-platform stuff and all the ASM they’ve got in System.pas, the diff view would be a big, confusing mess no matter what.)
Well, it’s getting late and I haven’t had time to dig through too much of the new stuff yet, (and with a new 1000-page novel and a new video game, it might be a while,) but overall this is looking like a pretty good release. Not a huge leap forward like the last two were, but a lot of polish and incremental improvements. I think this is going to be a pretty good release overall.
Excellent first look write up. I just finished installing too. For some reason my first 4 downloads got corrupted. It was probably my new download manager.
Oh, and the inclusion of Regular Expression support in the standard libraries is a great thing! Saying it is a bad thing because a regular expression might end up in code you have to support later is as bad as people who complain about Class Helpers. Regular expressions solve very specific types of problems really well, and for those types of problems they are probably the best solution. 1 regular expression can replace lines or even pages of other code.
Nice first look ! Your a little bit hard when saying that RegEx is a bad thing. I don’t think so, this could saves you a lot of time when properly used.
For the complie time, Annoying would be a better choice than bad 🙂
What TVirtualMethodInterceptor is useful for? You can do AOP (well in a limited way, but hey) with it. But after a first look I think it is just an experimental state because it intercepts every virtual method and crashes (either AV or Privileged Instruction Exception) when you Free the object you used it on.
[…] Na, schon Delphi XE gekauft? Heute, 08:45 Bin gerade durch diesen Blog Eintrag auf TVirtualMethodInterceptor aus der Rtti.pas aufmerksam geworden. Endlich!!! Delphi kann nun AOP […]
About regular expressions — where exactly would you like them to be if not in the core libraries?
Glad to see Generics are tightened up. In general, all the code cleanups is a good thing.
But I’m annoyed to have to pay a full update price AGAIN, just to finally use Generics without worries (I HOPE it is the final time!). I shall be looking out for people’s comments as they try the new Generics before laying down my money.
@Ken: still no parameterized interface methods though 🙁
Not to keen on RegExps either: they’re confusing like inline assembly, and they don’t have the excuse of being fast.
Ctrl+F2 has always been “Reset program” for all versions of Delphi I can recall back to 1.0 – it doesn’t just kill the debugger, it kills the running program.
regex – there have been not just acceptable but really very good and free regex libraries available for Delphi for some time already for that that wanted and needed them. The included library may even be, or based on, one of those free ones. It can’t hurt I suppose, as long as Embarcadero don’t kill the free, open source alternatives as they did when PNG support was stolen from the community so as to be able to sell it back to them.
Is the compiler slowdown a factor even when not using generics?
If so that’s not just bad it’s downright inconsiderate. 🙂
> I haven’t seen any 64-bit ifdefs [..]
Well, there’s quite some {$IFDEF CPUX64} in System.pas …
PhiS: Good catch. I updated the post with your info.
M: In Perl, and not anywhere in Delphi. 😛
I saw that in the Options/Environment Options/Delphi Options/Library there is new conditional define $(Platform) which is used in the Library Path and the Debug DCU path options. As of now $(Platform) is defined as “Win32”. So there is the future possibility to have other platforms used with Delphi compilers… 🙂
ChAr
Even if RegExp execution is slow (I’m not saying it is) I find that it is very fast in another way: coding time. It also serves as an (almost) industry-standard, cross-platform way of specifying functionality.
I agree that they can be hard to read, but some of that is due to lack of familiarity with them. I was the same way before I really dived in deep with RegExps. My suggestion: give them a fair trial and use them when and where appropriate.
@Joylon:
>Ctrl+F2 has always been “Reset program” for all versions of Delphi I can recall back to 1.0 – it doesn’t just kill the debugger, it kills the running program.
Yeah, I know. I meant the bug, not just the CTRL-F2.
>Is the compiler slowdown a factor even when not using generics?
It is, unfortunately. I asked Allen Bauer if there wasn’t some way it could just detect that your unit’s not using generics and skip the extra checking, and his response was basically “it’s not that simple.”
@Joylon: “as they did when PNG support was stolen from the community so as to be able to sell it back to them.”
It was not ‘stolen’ – the author (who was an individual person, not ‘the community’) never put an open source (let alone public domain) licence on it, and just stopped distributing it when he finally monetised all his hard work. For sure, CodeGear enforcing the original licence to the letter was a bit crappy, but who’s to say they originally demanded it in the first place? Perhaps they only did when it became clear the original author wasn’t going to donate the code as an act of charity.
That said, I personally give an open source licence to anything of my own I make public. I do however respect the right of others to act differently with their own code, and it’s a bit rich for you to disagree given you don’t appear to have donated much code to the ‘community’ yourself.
@Stefan – That’s a pity. Generics is the only reason I moved to D2010, thinking they’d had a version in which to mature.
At work we use C# and I find Generics part of my way of thinking now. I miss them when doing my home projects.
I’ll probably give this version a miss.
@Ken: I recently found this thread: http://stackoverflow.com/questions/2501016/delphi-2010-why-cant-i-declare-an-abstract-method-with-a-generic-type-paramete
Now I think I got a basic clue why we won’t see parameterized routines or methods in interfaces soon 🙁
I am a QA Engineer at Embarcadero and I work in the debugger team. I haven’t been able to reproduce your issue with the evaluator crashing the IDE while evaluating a call that will open a form. Can you provide steps for me so I can see this issue? Also, did you report this issue in Quality Central? If so, you can give me the QC report number and I can take a look so we can get this fixed if it really is an issue.
[…] A few weeks ago, I mentioned the release of The Way of Kings, the first installment of Brandon Sanderson’s new epic, The Stormlight Saga. I’ve had a bunch of other stuff distracting me since then, but this week I’ve finally put some time aside to read through it. And it did take all week. This is an enormous novel, 1000 pages in hardcover. Howard Tayler called it “the best argument you’ll have all year to get an e-reader, because you HAVE to have this book, but you might not be muscular enough to carry it around.” I’m going to disagree with that conclusion. Get the real novel. A digital display just won’t be able to do the beautiful, detailed illustrations in between some of the chapters justice. But he’s right that you have to have this book; it’s the Must Read Novel Of The Year if you’re into fantasy literature at all. […]
[…] mentioned the new generic collection TThreadedQueue<T> in my First Look at Delphi XE. I decided to play around with it a little recently. It’s useful for passing data between […]
[…] my first look at Delphi XE, I wrote: Oh, and apparently certain aspects of the compiler have slowed down. Most things will […]